#ifndef __ASM_MEMFAULT_H
#define __ASM_MEMFAULT_H
#include <asm/exception.h>
#include <asm/cpu_esr.h>

static inline bool is_write_abort(u32 esr)
{
	return (esr & ESR_ELx_WNR) && !(esr & ESR_ELx_CM);
}

static inline bool is_read_abort(u32 esr)
{
	return !(esr & ESR_ELx_WNR) && !(esr & ESR_ELx_CM);
}

typedef int (*mem_fault_func)(struct exception_spot *s, u64 fault_addr, u32 esr);
int mem_fault_unknown(struct exception_spot *s, u64 fault_addr, u32 esr);
int mem_fault_translation(struct exception_spot *s, u64 fault_addr, u32 esr);
int mem_fault_alignment(struct exception_spot *s, u64 fault_addr, u32 esr);
int mem_fault_access(struct exception_spot *s, u64 fault_addr, u32 esr);
int mem_fault(struct exception_spot *s, u64 fault_addr, u32 esr);
int user_vmem_fault(struct exception_spot *s, u64 fault_addr, u32 esr);
int kernel_mode_fault(struct exception_spot *s, u64 fault_addr, u32 esr);
#endif /* __ASM_MEMFAULT_H */
